package gui;

import data.Account;
import data.BankDatabase;

import javax.naming.ldap.Rdn;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class UserMenuDelete extends JPanel {

	private JLabel lbl_Header;
	private JComboBox comboBox_Delete;
	private JButton btn_Submit;
	private JButton btn_Back;
	private JLabel lbl_Intro;
	
	private BankDatabase bdb;
	private Screen screen;

	public UserMenuDelete(BankDatabase bdb, Screen screen) {

		this.screen = screen;
		this.bdb = bdb;
		
		setPreferredSize(new Dimension(550, 400));
		setLayout(null);
		
		lbl_Header = new JLabel("Delete Account");
		lbl_Header.setFont(new Font("SansSerif", Font.BOLD, 26));
		lbl_Header.setBounds(190, 50, 189, 34);
		add(lbl_Header);

		comboBox_Delete = new JComboBox();
		comboBox_Delete.setFont(new Font("SansSerif", Font.PLAIN, 16));
		comboBox_Delete.setBounds(157, 186, 250, 30);
		add(comboBox_Delete);
		
		btn_Submit = new JButton("Submit");
		btn_Submit.setFont(new Font("SansSerif", Font.PLAIN, 16));
		btn_Submit.setBounds(400, 300, 100, 40);
		add(btn_Submit);
		
		btn_Back = new JButton("Back");
		btn_Back.setFont(new Font("SansSerif", Font.PLAIN, 16));
		btn_Back.setBounds(67, 300, 100, 40);
		add(btn_Back);
		
		lbl_Intro = new JLabel("Which account do you want to delete?");
		lbl_Intro.setFont(new Font("SansSerif", Font.BOLD, 16));
		lbl_Intro.setBounds(138, 141, 291, 34);
		add(lbl_Intro);
	}
	
	public void addActionListener(ActionListener e){
		btn_Back.addActionListener(e);
		btn_Submit.addActionListener(e);
		comboBox_Delete.addActionListener(e);
	}

	public JButton getBack(){
		return btn_Back;
	}
	
	public JButton getSubmit(){
		return btn_Submit;
	}
	
	public JComboBox getComboBox() {
		return comboBox_Delete;
	}
		
	public void addAllAcc() {
		comboBox_Delete.removeAllItems();
		for (Account acc : bdb.getClassUser().getAccountList()) {
			   comboBox_Delete.addItem("Account: " + acc.getAccountNumber());
			}
		screen.pack();
	}
	
} // end UserMenuDelete class
